package com.linkme2night.model;

import java.io.Serializable;
import java.sql.Timestamp;


@SuppressWarnings("serial")
public final class Comment implements Serializable {

	private int clubberID;
	private int venueID;
	private String text;
	private Timestamp date;
	private final int MAX_CHARACTERS_ALLOWED = 260;

	public Comment(String text, Timestamp date, int clubberID, int venueID) {

		this.date = date;
		this.clubberID = clubberID;
		this.venueID = venueID;
		if (isCommentValid(text))
			this.text = text;
		else
			throw new RuntimeException(Comment.class.getSimpleName()
					+ " exceeded max allowed characters");
	}

	public String getText() {
		return text;
	}

	public Timestamp getDate() {
		return date;
	}

	public int getClubberID() {
		return clubberID;
	}

	public int getVenueID() {
		return venueID;
	}

	private boolean isCommentValid(String text) {
		// BR : empty text; max characters allowed
		return (text != null && !(text.trim().length() == 0))
				&& !(text.length() > MAX_CHARACTERS_ALLOWED);
	}

	public int getMaxAllowedCharacters() {
		return this.MAX_CHARACTERS_ALLOWED;
	}

}